import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/rds`

export function getRdsTableList(params) {
  return request.get(`${AUTH_PREFIX_V1}/tables`, { params }).then(res => camelCaseObject(res))
}

export function getRdsTableListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/tables/page`, { params }).then(res => camelCaseObject(res))
}

export function getRdsTable(tableId) {
  return request.get(`${AUTH_PREFIX_V1}/tables/${tableId}`).then(res => camelCaseObject(res))
}

export function createRdsTable(params) {
  return request.post(`${AUTH_PREFIX_V1}/tables`, params).then(res => camelCaseObject(res))
}

export function updateRdsTable(tableId, params) {
  return request.put(`${AUTH_PREFIX_V1}/tables/${tableId}`, params).then(res => camelCaseObject(res))
}

export function deleteRdsTable(tableId) {
  return request.delete(`${AUTH_PREFIX_V1}/tables/${tableId}`).then(res => camelCaseObject(res))
}
